//
//  CAKeyPath.m
//  Test
//
//  Created by xgc on 12/25/17.
//  Copyright © 2017 xgc. All rights reserved.
//

#import "CAKeyPath.h"


@implementation CAKeyPath

+(id)initWithKeyPath: (KeyPath*)path{

    CAKeyPath* keyPath = [[CAKeyPath alloc] init];
    keyPath.path1 = path->getPath1();
    keyPath.path2 = path->getPath2();
    keyPath.path3 = path->getPath3();
    keyPath.path4 = path->getPath4();
    keyPath.path5 = path->getPath5();
    keyPath.symbol = [NSString stringWithCString:path->getSymbol().c_str() encoding:[NSString defaultCStringEncoding]];
    keyPath.hd1 = path->getHd1() ? YES : NO;
    keyPath.hd2 = path->getHd2() ? YES : NO;
    keyPath.hd3 = path->getHd3() ? YES : NO;
    keyPath.hd4 = path->getHd4() ? YES : NO;
    keyPath.hd5 = path->getHd5() ? YES : NO;
    
    
    return keyPath;
    
}

-(KeyPath*)toKeyPath {
    KeyPath* keyPath = new KeyPath();
    keyPath->setPath1(self.path1);
    keyPath->setPath2(self.path2);
    keyPath->setPath3(self.path3);
    keyPath->setPath4(self.path4);
    keyPath->setPath5(self.path5);
    keyPath->setSymbol([self.symbol UTF8String]);
    keyPath->setHd1(self.hd1 == YES ? true : false);
    keyPath->setHd2(self.hd2 == YES ? true : false);
    keyPath->setHd3(self.hd3 == YES ? true : false);
    keyPath->setHd4(self.hd4 == YES ? true : false);
    keyPath->setHd5(self.hd5 == YES ? true : false);
    
    return keyPath;
}

-(id)init {
    if (self = [super init]) {
        self.path1 = -1;
        self.path2 = -1;
        self.path3 = -1;
        self.path4 = -1;
        self.path5 = -1;
        self.hd1 = NO;
        self.hd2 = NO;
        self.hd3 = NO;
        self.hd4 = NO;
        self.hd5 = NO;
    }
    return self;
}

@end
